package com.hk.aefz.shiro;

import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.shiro.crypto.hash.Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

@Getter
@NoArgsConstructor
public class Md5 {

//    散列次数 ，盐值加密次数
    public final int hashIterations = 20;
//    使用的加密算法
    public final String hashAlgorithmName = "MD5";

    /**
     * MD5盐值加密
     */
    public String md5yz(String credentials,String ysalt) {
        ByteSource salt = ByteSource.Util.bytes(ysalt);
        Hash hash = new SimpleHash(hashAlgorithmName, credentials, salt, hashIterations);
        return hash.toString();
    }

    public static void main(String[] args) {
        String hash = new Md5().md5yz("111111", "2568425312");
        System.out.println(hash.length());
    }

}
